#
# StartTCL: n
#
# ====================================
#
# Additional Spells & Effects script v2.1 (c) Delfin 
# creds: seatleson, BAD, DayDream
#
# ====================================

# 02.10.06 v2.3
# - Added newspellscripts by Iceman
# ----------------
# 29.08.06 v2.2
# - Added Aura
# - Added Judgement 
# ----------------
# 25.05.06 v2.1
# - Used Spirit's new custom "AddLegacySpellScript" procedure
# - Added Polymorph (commented)
# 19.05.06 v2.0
# - Added spell arrays
# - Made ExtraSpells script autonomous (thnx Lazarus & Spirit)
# - Reorganized Taunt
# ----------------
# 12.05.06 v1.2
# - Added FinishingMoves
# - Added Charge & Intercept
# ----------------
# 11.05.06 v1.1
# - Added Trinkets
# - Added Taunt
# ----------------
# 10.05.06 v1.0
# - First release / Cast Fear
# ____________________________________
#
#
# Start-TCL 0.9.4 compatible
#
# Fully Autonomous
#
#

##########
#
# defined namespaces
#
## Script Namespaces ##
namespace eval ::ExtraSpells { }

### Spells Namespaces ###
namespace eval ::ChargeSkills { }
namespace eval ::Fear { }
namespace eval ::FinishingMoves { }
namespace eval ::Polymorph { }
namespace eval ::Taunt { }
namespace eval ::Trinkets { }
namespace eval ::Aura { }
namespace eval ::Judgement { }
##########


#
# namespace ::ChargeSkills
#
 proc ::ChargeSkills::Charge { to from } { 
	::CastSpell $from $from 12695
 }

 proc ::ChargeSkills::ChargeStun { from } {
	set to [ ::GetSelection $from ]
	::CastSpell $from $to 7922
 }

 proc ::ChargeSkills::Intercept1 { to from } { 
	::CastSpell $from $from 14530
 }

 proc ::ChargeSkills::Intercept2 { to from } { 
	::CastSpell $from $from 17498
 }

 proc ::ChargeSkills::Intercept3 { to from } { 
	::CastSpell $from $from 22863
 }

 proc ::ChargeSkills::InterceptStun1 { from } {
	set to [ ::GetSelection $from ]
	::CastSpell $from $to 20253
 }

 proc ::ChargeSkills::InterceptStun2 { from } {
	set to [ ::GetSelection $from ]
	::CastSpell $from $to 20614
 }

 proc ::ChargeSkills::InterceptStun3 { from } {
	set to [ ::GetSelection $from ]
	::CastSpell $from $to 20615
 }


#
# namespace ::Fear
#
 proc ::Fear::OnCastFear { from to } {
	variable feartarget

	if { ! [info exists feartarget($from)] } {
		set feartarget($from) $to
	} elseif { $feartarget($from)!=$to } {
		::CastSpell $from $feartarget($from) 22891
		set feartarget($from) $to
	}
 }

#
# namespace ::FinishingMoves
#
 proc ::FinishingMoves::WrathHammer { to from spell } { 
	set hp [ ::GetHealthPCT $to ]
	if { $hp <= 20 } { 
		::CastSpell $from $to $spell 
	}
 }

 proc ::FinishingMoves::Execute { to from spell } { 
	set hp [ ::GetHealthPCT $to ]
	if { $hp <= 20 } {
		::CastSpell $from $to $spell 
	}
 }


#
# namespace ::Polymorph
#
# proc ::Polymorph::OnCastPolymorph { from to } {
#	global polymorphtarget
#	if { ! [info exists polymorphtarget($from)] } {
#		set polymorphtarget($from) $to
#	} elseif { $polymorphtarget($from)!= $to } {
#		::CastSpell $from $polymorphtarget($from) 22891
#		set polymorphtarget($from) $to
#	}
# }

#
# namespace ::Taunt
#
proc ::Taunt::OnCast { to from spellid } {
	::CastSpell $to $from 20508
}


#
# namespace ::Trinkets
#
 proc ::Trinkets::SixDemonBag { to from } {	
	set spell_list "23102 21402 15117 23103 15534 14642 "
	set spellid [lindex $spell_list [expr {int(rand()*[llength $spell_list])}]]
	::CastSpell $from $to $spellid
 }

 proc ::Trinkets::PiccoloOfTheFlamingFire { to from } {
	::Emote $to 10
 }		


#
# namespace ::Aura
#
 proc ::Aura::Cast { from spellid } { 
	::CastSpell $from $from $spellid
 }


#
# namespace ::Judgement
#
 proc ::Judgement::ClearAura { player } {            
	::ClearQFlag $player "auraright01"
	::ClearQFlag $player "auraright02"
	::ClearQFlag $player "auraright03"
	::ClearQFlag $player "auraright04"
	::ClearQFlag $player "auraright05"
	::ClearQFlag $player "auraright06"
	::ClearQFlag $player "auraright07"
	::ClearQFlag $player "auraright08"
	::ClearQFlag $player "auracommand01" 
	::ClearQFlag $player "auracommand02"
	::ClearQFlag $player "auracommand03" 
	::ClearQFlag $player "auracommand04"
	::ClearQFlag $player "auracommand05"
	::ClearQFlag $player "auralight01" 
	::ClearQFlag $player "auralight02" 
	::ClearQFlag $player "auralight03"
	::ClearQFlag $player "auralight04" 
	::ClearQFlag $player "aurawisd01"
	::ClearQFlag $player "aurawisd02"
	::ClearQFlag $player "aurawisd03" 
	return 0          
 }

 proc ::Judgement::Judge { player ennemy } {
	if {[::GetQFlag $player "auraright01"]} {
		::CastSpell $player $ennemy 20187
		Judgement::ClearAura $player   
		return 0        
	}  

	if {[::GetQFlag $player "auraright02"]} {
		::CastSpell $player $ennemy 20280
		Judgement::ClearAura $player
		return 0
	}

	if {[::GetQFlag $player "auraright03"]} {
		::CastSpell $player $ennemy 20281
		Judgement::ClearAura $player 
		return 0
	}

	if {[::GetQFlag $player "auraright04"]} {
		::CastSpell $player $ennemy 20282
		Judgement::ClearAura $player  
		return 0
	}

	if {[::GetQFlag $player "auraright05"]} {
		::CastSpell $player $ennemy 20283
		Judgement::ClearAura $player
		return 0
	}

	if {[::GetQFlag $player "auraright06"]} {
		::CastSpell $player $ennemy 20284
		Judgement::ClearAura $player   
		return 0
	}

	if {[::GetQFlag $player "auraright07"]} {
		::CastSpell $player $ennemy 20285
		Judgement::ClearAura $player  
		return 0
	}

	if {[::GetQFlag $player "auraright08"]} {
		::CastSpell $player $ennemy 20286
		Judgement::ClearAura $player  
		return 0
	}

	if {[::GetQFlag $player "auracommand01"]} {
		::CastSpell $player $ennemy 20467
		Judgement::ClearAura $player
		return 0
	}

	if {[::GetQFlag $player "auracommand02"]} {
		::CastSpell $player $ennemy 20963
		Judgement::ClearAura $player
		return 0
	}

	if {[::GetQFlag $player "auracommand03"]} {
		::CastSpell $player $ennemy 20964
		Judgement::ClearAura $player  
		return 0
	}

	if {[::GetQFlag $player "auracommand04"]} {
		::CastSpell $player $ennemy 20965
		Judgement::ClearAura $player 
		return 0
	}

	if {[::GetQFlag $player "auracommand05"]} {
		::CastSpell $player $ennemy 20966
		Judgement::ClearAura $player 
		return 0
	}

	if {[::GetQFlag $player "auralight01"]} {
		::CastSpell $player $player 50090
		Judgement::ClearAura $player 
		return 0
	}

	if {[::GetQFlag $player "auralight02"]} {
		::CastSpell $player $player 50091
		Judgement::ClearAura $player
		return 0
	}

	if {[::GetQFlag $player "auralight03"]} {
		::CastSpell $player $player 50092
		Judgement::ClearAura $player 
		return 0
	} 

	if {[::GetQFlag $player "auralight04"]} {
		::CastSpell $player $player 50093
		Judgement::ClearAura $player
		return 0
	}

	if {[::GetQFlag $player "aurawisd01"]} {
		::CastSpell $player $player 50094
		Judgement::ClearAura $player 
		return 0
	}

	if {[::GetQFlag $player "aurawisd02"]} {
		::CastSpell $player $player 50095
		Judgement::ClearAura $player   
		return 0
	}

	if {[::GetQFlag $player "aurawisd03"]} {
		::CastSpell $player $player 50096
		Judgement::ClearAura $player 
		return 0
	}

}   
###########       
 namespace eval newspellscripts {
 variable spell_scripts
#
# Stealth
#
proc ::newspellscripts::Stealth { to from spellid } { ::SetQFlag $from stealth }
::Custom::HookProc "::AI::CanAgro" {; if { [ ::GetQFlag $victim stealth ] } { return 0 } }
::Custom::HookProc "::WoWEmu::DamageReduction" { ::ClearQFlag $player stealth }
::Custom::AddSpellScript "::newspellscripts::Stealth" { 1784 1785 1786 1787 }
}
#
# Bads Spell fixes...
#
 proc ::newspellscripts::BadspellsAdds { to from spellid } {
  variable spell_scripts
  eval $spell_scripts($spellid)
}

#
# TameSpell
#
proc ::newspellscripts::tamespell { to from spellid } {
 if { [GetLevel $from] < [GetLevel $to] || [::Custom::GetElite $to] > 0 || [ ::GetCreatureType $to ] == 7 || [ ::GetCreatureType $to ] == 8 } { return "You can't Tame this!" }
 CastSpell $from $to 13481
}
::Custom::AddSpellScript "::PetSyStem::addonproc" 883
::Custom::AddSpellScript "::newspellscripts::tamespell" 13481
::Custom::AddSpellScript "::newspellscripts::BadspellsAdds" { [array names ::newspellscripts::spell_scripts] }



###########

proc ::ExtraSpells::Init { } {
	if { [ info exists "::StartTCL::VERSION" ] } {
	
		::Custom::AddSpellScript "::Taunt::OnCast" 355 694 1161 4092 4101 4507 5209 6795 7400 7402 9741 20559 20560 21008 21860 23790

		::Custom::AddLegacySpellScript {

			 5782 { Fear::OnCastFear $from $to }
			 6213 { Fear::OnCastFear $from $to }
			 6215 { Fear::OnCastFear $from $to }


			17512 { Trinkets::PiccoloOfTheFlamingFire $to $from}
			14537 { Trinkets::SixDemonBag $to $from}


			24275 { FinishingMoves::WrathHammer $to $from 11976 }
			24274 { FinishingMoves::WrathHammer $to $from 13584 }
			24239 { FinishingMoves::WrathHammer $to $from 12057 }	

			5308  { FinishingMoves::Execute $to $from 13446 }
			20658 { FinishingMoves::Execute $to $from 14516 }
			20660 { FinishingMoves::Execute $to $from 15580 }
			20661 { FinishingMoves::Execute $to $from 18368 }
			20662 { FinishingMoves::Execute $to $from 22591 }


			100   { ChargeSkills::Charge $to $from }
			6178  { ChargeSkills::Charge $to $from }
			11578 { ChargeSkills::Charge $to $from }

			12695 { ChargeSkills::ChargeStun $from }

			20252 { ChargeSkills::Intercept1 $to $from }
			20616 { ChargeSkills::Intercept2 $to $from }
			20617 { ChargeSkills::Intercept3 $to $from }

			14530 { ChargeSkills::InterceptStun1 $from }
			17498 { ChargeSkills::InterceptStun2 $from }
			22863 { ChargeSkills::InterceptStun3 $from }

			
			465   { Aura::Cast $from 50037 }
			10290 { Aura::Cast $from 50038 }
			643   { Aura::Cast $from 50039 }
			10291 { Aura::Cast $from 50040 }
			1032  { Aura::Cast $from 50041 }
			10292 { Aura::Cast $from 50042 }
			10293 { Aura::Cast $from 50043 }
			7294  { Aura::Cast $from 50044 }
      10298 { Aura::Cast $from 50045 }
      10299 { Aura::Cast $from 50046 }
      10300 { Aura::Cast $from 50047 }
      10301 { Aura::Cast $from 50048 }
			19876 { Aura::Cast $from 50049 }
			19895 { Aura::Cast $from 50050 }
			19896 { Aura::Cast $from 50051 }
			19888 { Aura::Cast $from 50052 }
			19897 { Aura::Cast $from 50053 }
			19898 { Aura::Cast $from 50054 }
			19891 { Aura::Cast $from 50055 }
			19899 { Aura::Cast $from 50056 }
			19900 { Aura::Cast $from 50057 }

			1130  { Aura::Cast $from 50058 }
			14323 { Aura::Cast $from 50059 }
			14324 { Aura::Cast $from 50060 }
			14325 { Aura::Cast $from 50061 }

			6673  { Aura::Cast $from 50062 }
			5242  { Aura::Cast $from 50063 }
			6192  { Aura::Cast $from 50064 }
			11549 { Aura::Cast $from 50065 }
			11550 { Aura::Cast $from 50066 }
			11551 { Aura::Cast $from 50067 }

			50024 { Aura::Cast $from 50068 }
			50025 { Aura::Cast $from 50069 }

			19506 { Aura::Cast $from 50109 }
			20905 { Aura::Cast $from 50110 }
			20906 { Aura::Cast $from 50111 }

			20043 { Aura::Cast $from 50118 }
			20190 { Aura::Cast $from 50119 }

			6940  { Aura::Cast $from 50120 }
			20729 { Aura::Cast $from 50121 }

                         

			50123 { Aura::Cast $from 20167 }
			50124 { Aura::Cast $from 20333 }
			50125 { Aura::Cast $from 20334 }
			50126 { Aura::Cast $from 20340 }

                       

			50147 { Aura::Cast $from 20168 }
			50148 { Aura::Cast $from 20350 }
			50149 { Aura::Cast $from 20351 }
			14278 { Aura::Cast $from 50127 }
		  8233  { Aura::Cast $from 50128 }
		  8236  { Aura::Cast $from 50129 }
		  10484 { Aura::Cast $from 50130 }
		  16361 { Aura::Cast $from 50131 }
		  8516  { Aura::Cast $from 50132 }
		  10608 { Aura::Cast $from 50133 }
		  10610 { Aura::Cast $from 50134 }
		  17364 { Aura::Cast $from 18941 }
		  20178 { Aura::Cast $from 18941 }
		  16459 { Aura::Cast $from 18941 }
		  12964 { Aura::Cast $from 50135 }
		  23602 { Aura::Cast $from 50135 }
			13797 { HunterTraps::DismissTrap $from }
			14298 { HunterTraps::DismissTrap $from }
			14299 { HunterTraps::DismissTrap $from }
			14300 { HunterTraps::DismissTrap $from }
			14301 { HunterTraps::DismissTrap $from }
			3355  { HunterTraps::DismissTrap $from }
			14308 { HunterTraps::DismissTrap $from }
			14309 { HunterTraps::DismissTrap $from }
			13810 { HunterTraps::DismissTrap $from }
			13812 { HunterTraps::DismissTrap $from }
			14314 { HunterTraps::DismissTrap $from }
			14315 { HunterTraps::DismissTrap $from }

			20187 {
			Judgement::ClearAura $from
			SetQFlag $from "auraright01"
			} 
			20287 { 
			Judgement::ClearAura $from
			SetQFlag $from "auraright02"
			} 
			20288 { 
			Judgement::ClearAura $from
			SetQFlag $from "auraright03"
			} 
			20289 { 
			Judgement::ClearAura $from
			SetQFlag $from "auraright04"
			} 
			20290 { 
			Judgement::ClearAura $from
			SetQFlag $from "auraright05"
			} 
			20291 { 
			Judgement::ClearAura $from
			SetQFlag $from "auraright06"
			} 
			20292 { 
			Judgement::ClearAura $from
			SetQFlag $from "auraright07"
			} 
			20293 { 
			Judgement::ClearAura $from
			SetQFlag $from "auraright08"
			} 
			20375 {
			Judgement::ClearAura $from
			SetQFlag $from "auracommand01"
			} 
			20915 {
			Judgement::ClearAura $from
			SetQFlag $from "auracommand02"
			} 
			20918 {
			Judgement::ClearAura $from
			SetQFlag $from "auracommand03"
			} 
			20919 {
			Judgement::ClearAura $from
			SetQFlag $from "auracommand04"
			} 
			20920 {
			Judgement::ClearAura $from
			SetQFlag $from "auracommand05"
			} 
			20165 {
			Judgement::ClearAura $from
			SetQFlag $from "auralight01"
			} 
			20347 {
			Judgement::ClearAura $from
			SetQFlag $from "auralight02"
			} 
			20348 {
			Judgement::ClearAura $from
			SetQFlag $from "auralight03"
			} 
			20349 {
			Judgement::ClearAura $from
			SetQFlag $from "auralight04"
			} 
			20166 {
			Judgement::ClearAura $from
			SetQFlag $from "aurawisd01"
			}
			20356 {
			Judgement::ClearAura $from
			SetQFlag $from "aurawisd02"
			}
			20357 {
			Judgement::ClearAura $from
			SetQFlag $from "aurawisd03"
			}
			20271 { Judgement::Judge $from $to }


		}

	} else {
		# setup the system to deal with these spells as usual
	}
}

::ExtraSpells::Init

